﻿@using ModalDownload.Models;
@{
    Layout = null;
    List<ModelTable> list = ModelTable.GetModels(ViewBag.Page, ViewBag.PageSize, ViewBag.Type);
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>ModelList</title>
    @Styles.Render("~/Content/admin/base.css")
    @Styles.Render("~/Content/admin/form.css")
    @Scripts.Render("~/bundles/jquery")
    <script>

    </script>
</head>
<body>
    <div>@using (Html.BeginForm("ModelList", "Admin", FormMethod.Post, new { name = "QueryModelListForm" }))
        {
            @Html.AntiForgeryToken()
            @Html.ValidationSummary(true)
            <table id="tableList" class="editForm" cellpadding="0" cellspacing="0">
                <tr>
                    <td style="width:10%"></td>
                    <td style="width:30%"></td>
                    <td style="width:30%"></td>
                    <td style="width:30%"></td>
                </tr>
                <tr>
                    <td class="fieldLable">@Html.LabelForModel("分类")</td>
                    <td class="fieldLable">@Html.DropDownList("class")</td>
                    <td><input class="btn-" name="Submit1" type="submit" value="查询" /></td>
                    <td></td>
                </tr>
            </table>
        }
        <br/>
        <table id="tableList" class="editList" cellpadding="0" cellspacing="0">
			<tr>
				<td colspan="8">
					@Html.ActionLink("添加新资源","Publish")
				</td>
			</tr>
			<tr class="head">
				<td class="center">
					图片
				</td>
				<td class="center">
					标题
				</td>
				<td class="center">
					内容
				</td>
				<td class="center">
					发布时间
				</td>
				<td class="center">
					推荐
				</td>
				<td class="center">
					热门
				</td>
				<td class="center">
					相 关 操 作
				</td>
			</tr>
            @foreach (ModelTable model in list)
            {
                <tr class="alternate">
                    <td class="center" width="130">
                        <img src="../Images/Upload/@(model.imagefilename)"  width="80%" style="margin-top:5px;" />
                    </td>
                    <td class="center">
                        @(model.title)
                    </td>
                    <td class="center" width="25%">
                        @(model.descirption.Length>20?(model.descirption.Substring(0,20)+"..."):model.descirption)
                    </td>
                    <td class="center">
                        @(model.createTime.ToString("yyyy-MM-dd HH:mm:ss"))
                    </td>
                    <td class="center">
                        @(model.recommend?"是":"否")
                    </td>
                    <td class="center">
                        @(model.hot?"是":"否")
                    </td>
                    <td class="center">
                        @Html.ActionLink("修改", "Publish", new { viewmode = "edit", id = model.ID })&nbsp;&nbsp;&nbsp;&nbsp;
                        @Html.ActionLink("删除", "Publish", new { viewmode = "delete", id = model.ID }, new { onclick="return window.confirm('删除资源将无法恢复，是否删除！？');" })
                    </td>
                </tr>
            }
			<tr>
				<td class="center" colspan="8">
					总数：<b>@ViewBag.Total</b>&nbsp;&nbsp;&nbsp;&nbsp;
    @if (ViewBag.Page==1){
        @:首页&nbsp;&nbsp;&nbsp;&nbsp;上一页
    }
    else
    {
        @Html.ActionLink("首页", "ModelList", "Admin", new { type=ViewBag.Type,page="1"},null)
        @:&nbsp;&nbsp;&nbsp;&nbsp
        @Html.ActionLink("上一页", "ModelList", "Admin", new { type=ViewBag.Type,page=(ViewBag.Page-1)},null) 
    }
            &nbsp;&nbsp;&nbsp;&nbsp;
    @if (ViewBag.PageLength <= ViewBag.Page)
    {
        @:下一页&nbsp;&nbsp;&nbsp;&nbsp;尾页
    }
    else
    {
        @Html.ActionLink("下一页", "ModelList", "Admin", new { type=ViewBag.Type,page=(ViewBag.Page+1)},null)
        @:&nbsp;&nbsp;&nbsp;&nbsp
        @Html.ActionLink("尾页", "ModelList", "Admin", new { type=ViewBag.Type,page=ViewBag.PageLength},null) 
    }
    &nbsp;&nbsp;&nbsp;&nbsp;页: <b><font color="red">@ViewBag.Page</font>/@ViewBag.PageLength</b>
				</td>
			</tr>
		</table>
    </div>
</body>
</html>
